{{/*
Global annotations check
*/}}
{{- define "global.annotations.check" -}}
{{- range $index, $val := .Values.items -}}
{{- if and (eq $val.type "global") $val.annotations -}}
{{- print "true" -}}
{{- end }}{{- end }}{{- end }}

{{/*
Global containers envs check
*/}}
{{- define "global.containers.envs.check" -}}
{{- range $index, $val := .Values.items -}}
{{- if and (eq $val.type "global") (not (empty $val.containers)) (eq (len $val.containers) 1) -}}
{{- range $_, $containers := $val.containers }}
{{- if not (empty $containers.envs) }}
{{- print "true" -}}
{{- end }}{{- end }}{{- end }}
{{- end }}{{- end }}

{{/*
Global containers extra envs check
*/}}
{{- define "global.containers.extraEnvs.check" -}}
{{- range $index, $val := .Values.items -}}
{{- if and (eq $val.type "global") (not (empty $val.containers)) (eq (len $val.containers) 1) -}}
{{- range $_, $containers := $val.containers }}
{{- if not (empty $containers.extraEnvs) }}
{{- print "true" -}}
{{- end }}{{- end }}{{- end }}
{{- end }}{{- end }}

{{/*
Global containers registry
*/}}
{{- define "global.containers.registry" -}}
{{- range $index, $val := .Values.items -}}
{{- if and (eq $val.type "global") (not (empty $val.containers)) (eq (len $val.containers) 1) -}}
{{- range $_, $containers := $val.containers }}
{{- if not (empty $containers.registry) }}
{{- printf "%v" $containers.registry -}}
{{- end }}{{- end }}{{- end }}
{{- end }}{{- end }}


{{/*
Global init-containers envs check
*/}}
{{- define "global.initContainers.envs.check" -}}
{{- range $index, $val := .Values.items -}}
{{- if and (eq $val.type "global") (not (empty $val.initContainers)) (eq (len $val.initContainers) 1) -}}
{{- range $_, $containers := $val.initContainers }}
{{- if not (empty $containers.envs) }}
{{- print "true" -}}
{{- end }}{{- end }}{{- end }}
{{- end }}{{- end }}

{{/*
Global init-containers extra envs check
*/}}
{{- define "global.initContainers.extraEnvs.check" -}}
{{- range $index, $val := .Values.items -}}
{{- if and (eq $val.type "global") (not (empty $val.initContainers)) (eq (len $val.initContainers) 1) -}}
{{- range $_, $containers := $val.initContainers }}
{{- if not (empty $containers.extraEnvs) }}
{{- print "true" -}}
{{- end }}{{- end }}{{- end }}
{{- end }}{{- end }}

{{/*
Global init-containers registry
*/}}
{{- define "global.initContainers.registry" -}}
{{- range $index, $val := .Values.items -}}
{{- if and (eq $val.type "global") (not (empty $val.initContainers)) (eq (len $val.initContainers) 1) -}}
{{- range $_, $containers := $val.initContainers }}
{{- if not (empty $containers.registry) }}
{{- print "%v" $containers.registry -}}
{{- end }}{{- end }}{{- end }}
{{- end }}{{- end }}
